<include file='./header' />
<load href="__PUBLIC__/Css/pagination.css" / > 
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
<!--<script type="text/javascript" src="__ROOT__/js/zc.js"></script>-->
<script type="text/javascript">
var wait1=60;
var wait2=60;
var wait3=60;
$(function() {
	tabs(".userSetup_tabs","on",".userSetup_con");
	tabs(".mobileManage_tab","on",".mobileManage_con");
	var userMobile = {$userMobile};
	
	/********************修改密码*****************/
	$("#txtoldpwd").blur(function(){checkLoginPw(this,"#spanoldpwd")});//原密码空值判断
	$("#txtnewpwd").blur(function(){checkPassword(this,"#spannewpwd")});//新密码格式判断
	$("#show_password1").click(function(){swichPassword(this,"#txtnewpwd")});//显示和隐藏密码	
	$("#txtrenewpwd").blur(function(){confirmPassword("#txtnewpwd",this,"#spanrenewpwd")});//判断两次密码输入是否一致
	/*修改密码提交判断*/
	$("#btnPasswordReset").click(function(){
										
		if(!checkLoginPw("#txtoldpwd","#spanoldpwd")){return false;}//原密码空值判断
		if(!checkPassword("#txtnewpwd","#spannewpwd")){return false;}//新密码格式判断
		if(!confirmPassword("#txtrenewpwd","#txtnewpwd","#spanrenewpwd"))
		{
			return false;}
		else{
			oldpwd = $("#txtoldpwd").val();
			newpwd = $("#txtnewpwd").val();
			
			ajaxUpdatePwd(oldpwd,newpwd);
		}
	})
	
	/********************修改手机号码*****************/
	$("#txtSmsCode1").blur(function(){checkConfirm1(this,"#spanConfirm1")});//原手机验证码格式判断
	//$("#getCode1").click(function(){
	//	time(this,wait1);	//原手机发送验证码倒计时
	//});
	$("#txtMobile2").blur(function(){
	    checkMobile(this,"#spanMobile2","#getCode2");
	    isSameMobile(userMobile,$("#txtMobile2").val());
	    });
	$('#txtMobile2').bind('input propertychange', function() {    	
		var txtMobile = $("#txtMobile2").val();
   		if(txtMobile.length == 11){
		checkMobile("#txtMobile2","#spanMobile2","#getCode2");	//新手机号码格式判断   
		isSameMobile(userMobile,$("#txtMobile2").val()); //判断新旧手机号是否相同
    }
    });
	$("#txtSmsCode2").blur(function(){checkConfirm1(this,"#spanConfirm2")});//新手机验证码格式判断
	
	$("#getCode2").click(function(){
	    var newMobile = $("#txtMobile2").val();
		if(!checkMobile("#txtMobile2","#spanMobile2","#getCode2")){
			return false;
		}else if(newMobile == userMobile)
		{
		    $("#spanMobile2").html("<i class='fa fa-times-circle'></i>手机号码不能相同</span>").show();
		    return false;
		}
		else{
			time(this,wait2);//新手机发送验证码倒计时
			$.ajax({  
            type: "post",  
            url: "__GROUP__/User/getCode",
            dataType: 'json',
            data: {mobile:newMobile,type:'reg'}, 
            beforeSend: function(XMLHttpRequest){
                $("#spanMobile2").html("<i class='fa fa-check-circle'></i>验证码已发出</span>").show();
            },  
            success: function(json){
                if(json.data > 0){
                    $("#spanMobile2").html("<i class='fa fa-check-circle'></i>短信发送成功</span>").show();
                }else if(json.data == -99){
                    $("#spanMobile2").html("<i class='fa fa-times-circle'></i>短信请求次数过多</span>").show();
                }
                else if(json.data == -3){
                    $("#spanMobile2").html("<i class='fa fa-times-circle'></i>您的手机号已存在</span>").show();  
                }
            } 
            })
		}
	});	
	/*修改手机号码提交判断*/
	$("#btnMobileReset").click(function(){
	    var pwd = $("#txtPwd").val();
	    var newMobile = $("#txtMobile2").val();
	    var smscode = $("#txtSmsCode2").val();
	    
		//if(!checkConfirm1("#txtSmsCode1","#spanConfirm1")){return false;}//原手机验证码格式判断
		if(!checkMobile("#txtMobile2","#spanMobile2","#getCode2")){return false;}//新手机号码格式判断
		if(!checkConfirm1("#txtSmsCode2","#spanConfirm2")){return false;}//新验证码格式判
		else{
			//alert("OK!");
			ajaxChangeMobile(pwd,newMobile,smscode);
		}
	})
	/********************解除绑定手机*****************/
	//$("#txtSmsCode3").blur(function(){checkConfirm1(this,"#spanConfirm3")});//验证码格式判断
	/*$("#getCode3").click(function(){
		time(this,wait3);	//发送验证码倒计时
	});*/
	$("#btnMobileRemove").click(function(){
		if(!checkConfirm1("#txtSmsCode3","#spanConfirm3")){return false;}
		else{
			alert("OK!");
		}
	})
	/********************修改邮箱地址*****************/
	$("#txtEmail2").blur(function(){checkEmail(this,"#spanEmail")});
	$("#btnEmailReset").click(function(){
		if(!checkEmail("#txtEmail2","#spanEmail")){return false;}
		else{
			alert("OK!");
		}
	})
	
})

//判断手机号是否相同
function isSameMobile(oldMobile,newMobile)
{
        if(oldMobile == newMobile)
        {
            
            $("#spanMobile2").html("<i class='fa fa-times-circle'></i>手机号码不能相同</span>").show();
            $("#getCode2").css("cursor","not-allowed").attr({"class":"btn btn-default","disabled":true});
            return false;
        }
        return true;
}

//修改手机号
function ajaxChangeMobile(pwd,newMobile,smscode)
{
      $.ajax({  
        type: "post",  
        url: "__URL__/changeMobile",  
        dataType: 'json',
        data: {'pwd':pwd,'newMobile':newMobile,'smscode':smscode},
        beforeSend: function(XMLHttpRequest){  
        },  
        error:function(){
            alert('error');
        },
        success: function(json)
        {
            //alert('success!');
            if(json.status == 1){
                alert(json.info);
                $("#txtMobile1").html(newMobile).show();
            } else
            {
                alert(json.info);
            }
        }                          
    })
}

function ajaxUpdatePwd(oldpwd,newpwd)
{
     $.ajax({  
		type: "post",  
		url: "__URL__/updatePwd",  
		dataType: 'json',
		data: {'oldpwd':oldpwd,'newpwd':newpwd},
		beforeSend: function(XMLHttpRequest){  
		},  
		error:function(){
			alert('error');
		},
		success: function(json)
		{
			//alert('success!');
			if(json.status == 1){
				alert(json.info);
			} else
			{
				alert(json.info);;
			}
		}                          
	})
	
}

</script>
</head>
<body>
<!--顶部开始-->
<include file="./top" />
<!--顶部结束-->
<!--左导航开始-->
<include file="./left" />
<!--左导航结束-->

<!--主体开始-->
<div class="main-content">
	<div class="wrapper">
		<div class="panel">
            <div class="panel-head">
                帐号设置
            </div>
            <div class="panel-body">               
				<div class="userSetup_tabs">
                	<span class="on"><i class="fa fa-list"></i>登录日志</span>
                    <span><i class="fa fa-key"></i>修改密码</span>
                    <span><i class="fa fa-mobile"></i>手机绑定</span>
                   <!-- <span><i class="fa fa-envelope"></i>邮箱绑定</span> -->
                </div>
              <div class="userSetup_con">
                	<!--登录日志-->
                    <div class="userSetup_con_list">
                    	<table class="table table-blue table-bordered">
                          <thead>
                              <tr>
                                <!--<th><i class="fa fa-calendar"></i>日期</th>-->
                                <th><i class="fa fa-clock-o"></i>时间</th>
                                <th><i class="fa fa-map-marker"></i>地点</th>
                                <th><i class="fa fa-desktop"></i>登录方式</th>
                              </tr>
                          </thead>
                          <tbody>
                            <?php foreach ($list as $k => $v):?>
                            <tr>
                                <!--<td rowspan="3">昨天</td>-->
                                <td>{$v['createtime']}</td>
                                <td>{$v['ip']}</td>
                                <td>{$v['login_type']}</td>
                            </tr>
                           <?php endforeach?>
                          </tbody>
                        </table>
                          <div class="pagination">{$page}</div>
                    </div>
                    <!--修改密码-->
                    <div class="userSetup_con_list">
                    	<div class="passwordReset">
                        	<p>
                            	<label>当前密码：</label>
                                <input type="password" id="txtoldpwd" class="form-control" name="" placeholder="输入您的原密码">
                                <span style="display:none;" class="notice_wrong" id="spanoldpwd"></span>
                            </p>
                            <p>
                            	<label>新密码：</label>
                                <input id="txtnewpwd" class="form-control" name="" type="password" maxlength="12" placeholder="长度在6-12之间，只能包含字符、数字和下划线">
                                <a id="show_password1" href="javascript:void(0)" class="btn btn-success btn-ms showpw"><i class="fa fa-eye"></i></a>
                                <span style="display:none;" class="notice_wrong" id="spannewpwd"></span>
                            </p>
                            <p>
                            	<label>确认密码：</label>
                                <input type="password" id="txtrenewpwd" class="form-control" name="" maxlength="12" placeholder="再次输入上面新设置的密码">
                                <span style="display:none;" class="notice_wrong" id="spanrenewpwd"></span>
                            </p>
                            <p>
                            	<label>&#12288;</label>
                                <input type="button" id="btnPasswordReset" class="close-reveal-modal btn btn-danger" value="保 存">
                            </p>
                            <div class="clear"></div>
                        </div>
                    </div>
                    <!--手机绑定-->
                    <div class="userSetup_con_list">
                    	
                        <div class="clear"></div>
                        <div class="mobileManage_tab">
                        	<span class="on"><i class="fa fa-refresh"></i>更改手机</span>
                            <!--<span><i class="fa fa-unlock"></i>解绑手机</span>-->
                        </div>
                        <div class="mobileManage_con">
                        	 <!--更改手机-->
                             <div class="mobileManage_con_list">
                             	<div class="mobileReset">
                                    <p>
                                        <label>原手机号码：</label>
                                        <b class="text-danger" id="txtMobile1">{$userMobile}</b>
                                    </p>
                                    <!--<p>
                                        <label>原手机验证码：</label>
                                        <input type="text" id="txtSmsCode1" maxlength="4" placeholder="原手机的验证码" class="form-control" name="">
                                        <button id="getCode1" class="btn btn-danger btn-sm" type="button">获取验证码</button>
                                        <span id="spanConfirm1" class="notice_wrong"></span>
                                    </p>-->
                                    <p>
                                        <label>输入密码：</label>
                                        <input id="txtPwd" class="form-control" type="password" placeholder="输入您的登录密码" name="">
                                        <span class="notice_wrong" id=""></span>
                                    </p>
                                    <p>
                                        <label>新手机号码：</label>
                                        <input id="txtMobile2" class="form-control" type="text" maxlength="11" placeholder="输入新的手机号码" name="">
                                        <button id="getCode2" class="btn btn-default btn-sm" disabled="disabled" style="cursor: not-allowed;" type="button">获取验证码</button>
                                        <span class="notice_wrong" id="spanMobile2"></span>
                                    </p>
                                    <p>
                                        <label>新手机验证码：</label>
                                        <input type="text" id="txtSmsCode2" maxlength="4" placeholder="新手机的验证码" class="form-control" name="">
                                        <span id="spanConfirm2" class="notice_wrong"></span>
                                    </p>
                                    <p>
                                        <label>&#12288;</label>
                                        <input type="button" id="btnMobileReset" class="close-reveal-modal btn btn-danger" value="保 存">
                                    </p>
                                    <div class="clear"></div>
                                </div>
                             </div>
                             <!--解绑手机-->
                             <div class="mobileManage_con_list">
                             	<div class="userSetupNotice">
                                    <i class="fa fa-exclamation-circle"></i>解除绑定手机号码您可以用已绑定的邮箱 <b>pret****@126.com</b> 登录，请谨慎操作！
                                </div>
                                <div class="mobileReset">                                    
                                    <p>
                                        <label>手机号码：</label>
                                        <b class="text-danger" id="txtMobile3">186*****506</b>
                                    </p>
                                    <!--<p>
                                        <label>验证码：</label>
                                        <input type="text" id="txtSmsCode3" maxlength="4" placeholder="输入验证码" class="form-control" name="">
                                        <button id="getCode3" class="btn btn-danger btn-sm" type="button">获取验证码</button>
                                        <span id="spanConfirm3" class="notice_wrong"></span>
                                    </p>-->
                                    <p>
                                        <label>输入密码：</label>
                                        <input id="" class="form-control" type="password" placeholder="输入您的登录密码" name="">
                                        <span class="notice_wrong" id=""></span>
                                    </p>
                                    <p>
                                        <label>&#12288;</label>
                                        <input type="button" id="btnMobileRemove" class="close-reveal-modal btn btn-danger" value="解 除">
                                    </p>
                                    <div class="clear"></div>
                                </div>
                             </div>
                        </div>
                        <div class="clear"></div>
                    </div>
                    <!--邮箱绑定-->
                    <div class="userSetup_con_list">
                    	<div class="mobileNow right">已绑定邮箱：<b class="text-danger">pret****@126.com</b></div>
                        <div class="clear"></div>
                        <div class="mobileManage_tab">
                        	<span class="on"><i class="fa fa-refresh"></i>更改邮箱</span>
                            <span><i class="fa fa-unlock"></i>解绑邮箱</span>
                        </div>
                        <div class="mobileManage_con">
                        	 <!--更改邮箱-->
                             <div class="mobileManage_con_list">
                             	<div class="mobileReset">
                                    <p>
                                        <label>原邮箱地址：</label>
                                        <b class="text-danger" id="txtEmail1">pret****@126.com</b>
                                    </p>
                                    <p>
                                        <label>输入密码：</label>
                                        <input id="" class="form-control" type="password" placeholder="输入您的登录密码" name="">
                                        <span class="notice_wrong" id=""></span>
                                    </p>
                                    <p>
                                        <label>新邮箱地址：</label>
                                        <input type="text" id="txtEmail2" placeholder="输入新的邮箱地址" class="form-control" name="">
                                        <button id="" class="btn btn-danger btn-sm" type="button">发送邮箱验证码</button>
                                        <span class="notice_wrong" id="spanEmail"></span>
                                    </p>
                                    <p>
                                        <label>邮箱验证码：</label>
                                        <input type="text" id="" maxlength="4" placeholder="您的邮箱验证码" class="form-control" name="">
                                        <span id="" class="notice_wrong"></span>
                                    </p>
                                    <p>
                                        <label>&#12288;</label>
                                        <input type="button" id="btnEmailReset" class="close-reveal-modal btn btn-danger" value="确 定">
                                    </p>
                                    <div class="clear"></div>
                                </div>
                             </div>
                             <!--解绑邮箱-->
                             <div class="mobileManage_con_list">
                             	<div class="userSetupNotice">
                                    <i class="fa fa-exclamation-circle"></i>解除绑定邮箱地址您可以用已绑定的手机 <b>186*****506</b> 登录，请谨慎操作！
                                </div>
                                <div class="mobileReset">                                    
                                    <p>
                                        <label>邮箱地址：</label>
                                        <b class="text-danger" id="txtEmail3">pret****@126.com</b>
                                    </p>
                                    <p>
                                        <label>输入密码：</label>
                                        <input id="" class="form-control" type="password" placeholder="输入您的登录密码" name="">
                                        <span class="notice_wrong" id=""></span>
                                    </p>
                                    <p>
                                        <label>&#12288;</label>
                                        <input type="button" id="btnEmailRemove" class="close-reveal-modal btn btn-danger" value="解 除">
                                    </p>
                                    <div class="clear"></div>
                                </div>
                             </div>
                        </div>
                        <div class="clear"></div>
                    </div>
              </div>
              <div class="clear"></div>
                
          </div>
        </div>
    </div>
</div>
<!--主体结束-->
<!--底部开始-->
<include file="./foot" />
<!--底部结束-->
</body>
</html>
